﻿// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
#include "Engine.h"

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}


int sbeidc_create(void** handle, sbeidc_cfg* cfg/* = nullptr*/) {
	Engine* engine = new Engine;

	if (cfg->pfs > 0) {
		engine->setFps(cfg->pfs);
	}

	if (cfg->max_frame != 0) {
		engine->setMaxFrame(cfg->max_frame);
	}

	if (engine->Init() != 0) {
		return -1;
	}

	*handle = reinterpret_cast<void*>(engine);

	return 0;
}

int sbeidc_start(void* handle, sbeidc_cb* callBack/* = nullptr*/) {
	Engine* engine = reinterpret_cast<Engine*>(handle);
	engine->setCb(callBack);
	return engine->Start();
}

void sbeidc_wait(void* handle) {
	Engine* engine = reinterpret_cast<Engine*>(handle);
	engine->Wait();
}

int sbeidc_stop(void* handle) {
	Engine* engine = reinterpret_cast<Engine*>(handle);
	return engine->Stop();
}

void sbeidc_release(void* handle) {

	Engine* engine = reinterpret_cast<Engine*>(handle);
	delete engine;
}

